<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回指定的字符</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.chr" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">chr</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">chr</span> &mdash; <span class="dc-title">返回指定的字符</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.chr-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>chr</strong></span>
    ( <span class="methodparam"><span class="type">int</span> <code class="parameter">$ascii</code></span>
   ) : <span class="type">string</span></div>

  <p class="para rdfs-comment">
   返回相对应于 <code class="parameter">ascii</code>
   所指定的单个字符。
  </p>
  <p class="para">
   此函数与 <span class="function"><a href="ord.html" class="function">ord()</a></span> 是互补的。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.chr-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<code class="parameter">ascii</code></dt>

     <dd>

      <p class="para">
       Ascii 码。
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chr-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回规定的字符。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.chr-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5893">
    <p><strong>Example #1 <span class="function"><strong>chr()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #DD0000">"The&nbsp;string&nbsp;ends&nbsp;in&nbsp;escape:&nbsp;"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">.=&nbsp;</span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">27</span><span style="color: #007700">);&nbsp;</span><span style="color: #FF8000">/*&nbsp;在&nbsp;$str&nbsp;后边增加换码符&nbsp;*/<br /><br />/*&nbsp;通常这样更有用&nbsp;*/<br /><br /></span><span style="color: #0000BB">$str&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">sprintf</span><span style="color: #007700">(</span><span style="color: #DD0000">"The&nbsp;string&nbsp;ends&nbsp;in&nbsp;escape:&nbsp;%c"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">27</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.chr-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="sprintf.html" class="function" rel="rdfs-seeAlso">sprintf()</a> - Return a formatted string</span> 如何使用格式字符串 <em>%c</em>。</li>
    <li class="member"><span class="function"><a href="ord.html" class="function">ord()</a></span></li>
    <li class="member">可以在此处找到 ASCII 码表：<a href="http://www.asciitable.com" class="link external">&raquo;&nbsp;http://www.asciitable.com</a>。</li>
   </ul>
  </p>
 </div>

</div></div></div></body></html>